package com.bianmaba.spring.supports.mvc.annotations;

import com.bianmaba.spring.supports.data.repository.ExtendedRepositoryImpl;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.annotation.AliasFor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean;
import org.springframework.data.repository.query.QueryLookupStrategy;

import java.lang.annotation.*;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@EnableJpaRepositories(repositoryBaseClass = ExtendedRepositoryImpl.class)
public @interface EnableJpaRepositoriesExtension {
    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "value")
    String[] value() default {};

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "basePackages")
    String[] basePackages() default {};

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "basePackageClasses")
    Class<?>[] basePackageClasses() default {};

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "includeFilters")
    ComponentScan.Filter[] includeFilters() default {};

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "excludeFilters")
    ComponentScan.Filter[] excludeFilters() default {};

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "repositoryImplementationPostfix")
    String repositoryImplementationPostfix() default "Impl";

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "namedQueriesLocation")
    String namedQueriesLocation() default "";

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "queryLookupStrategy")
    QueryLookupStrategy.Key queryLookupStrategy() default QueryLookupStrategy.Key.CREATE_IF_NOT_FOUND;


    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "repositoryFactoryBeanClass")
    Class<?> repositoryFactoryBeanClass() default JpaRepositoryFactoryBean.class;

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "entityManagerFactoryRef")
    String entityManagerFactoryRef() default "entityManagerFactory";

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "transactionManagerRef")
    String transactionManagerRef() default "transactionManager";

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "considerNestedRepositories")
    boolean considerNestedRepositories() default false;

    @AliasFor(annotation = EnableJpaRepositories.class, attribute = "enableDefaultTransactions")
    boolean enableDefaultTransactions() default true;
}
